<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  "use strict";
  const copy = obj => {
    let res = obj instanceof Array ? [] : {};
    for (let [key, value] of Object.entries(obj)) {
      res[key] = typeof value == "object" ? copy(value) : value;
    };
    return res;
  };

  // 第二中拷贝的方法(不能拷贝日期/函数)
  let obj = {
    name: "cz",
    hobdy: ["打球", "看书", "写字"],
    sing: {
      "name": "李香兰",
      "song": "张学友"
    }
  };
  let obj1 = JSON.parse(JSON.stringify(obj));
  console.log(obj1);
</script>

</html>